#include <iostream>

using std::cout;
using std::endl;

void func()
{
    cout << "void func()" << endl;
}

class Example
{
public:
    void print(int x)
    {
        cout << "void Example::print()" << endl;
    }
};

void test()
{
    void (*pFunc)() = &func;
    pFunc();

    int number = 10;
    int *pInt = &number;

    /* pFunc = &Example::print;//error */
    //成员函数指针的定义
    void (Example::*pFunction)(int) = &Example::print;
    Example ex;
    //成员函数指针的使用
    (ex.*pFunction)(100);
    ex.print(100);

    cout << endl;
    Example *ptr = &ex;
    (ptr->*pFunction)(200);
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

